PREFIX=/usr/local
DESTDIR=
GOFLAGS=-ldflags "-w -s"
BLDDIR = build
EXT=
CURRDIR=$(shell pwd)


# 如果是windows平台，则增加.exe扩展名
ifeq (${GOOS},windows)
    EXT=.exe
endif

# 定义应用
APPS = annualbalance
all: $(APPS)

# 定义应用的编译目录
$(BLDDIR)/annualbalance:        $(wildcard cmd/annualbalance/*.go)
$(BLDDIR)/instantbalance:        $(wildcard cmd/instantbalance/*.go)

# 编译应用
$(BLDDIR)/%:
	@mkdir -p $(dir $@)
	go build ${GOFLAGS} -o $@${EXT} ./cmd/$*

$(APPS): %: $(BLDDIR)/%

clean:
	rm -fr $(BLDDIR)/*

.PHONY: install clean all
.PHONY: $(APPS)
